package com.zbec.mdrs.entity.report;

import com.zbec.framework.core.entity.IdEntity;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;


@Entity
@Table(name = "TB_REPORT_FILE")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class ReportFile extends IdEntity {

    private ReportTask task;
	private String fileName;
	private String fileUrl;
	private String fileType;
	private String reportMan;
	private Date reportDate;

    private Set<ReportFileRel> rels = new HashSet<ReportFileRel>();

    @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.LAZY)
    @JoinColumn(name = "TASK_ID", referencedColumnName = "ID")
    @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
    public ReportTask getTask() {
        return task;
    }

    public void setTask(ReportTask task) {
        this.task = task;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getFileUrl() {
        return fileUrl;
    }

    public void setFileUrl(String fileUrl) {
        this.fileUrl = fileUrl;
    }

    public String getFileType() {
        return fileType;
    }

    public void setFileType(String fileType) {
        this.fileType = fileType;
    }

    public String getReportMan() {
        return reportMan;
    }

    public void setReportMan(String reportMan) {
        this.reportMan = reportMan;
    }

    public Date getReportDate() {
        return reportDate;
    }

    public void setReportDate(Date reportDate) {
        this.reportDate = reportDate;
    }

    @OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.LAZY)
    @JoinColumn(name = "FILE_ID")
    @OrderBy("id")
    @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
    public Set<ReportFileRel> getRels() {
        return rels;
    }

    public void setRels(Set<ReportFileRel> rels) {
        this.rels = rels;
    }
}